package com.yk.framework.gui.ctrl;

import java.awt.Component;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JDialog;

import com.yk.framework.icons.IconReader;

/**
 * @author lifetime
 * 
 */
@SuppressWarnings("serial")
public class YKDialog extends JDialog implements KeyListener {

	public YKDialog() {
		super();
		init();
	}

	protected void init() {
		this.addKeyListener(this);
		this.requestFocusInWindow(true);
		setIconImage(Toolkit.getDefaultToolkit().getImage(IconReader.class.getResource("yk_logo.png")));
	}

	public Component add(Component c) {
		c.addKeyListener(this);
		return super.add(c);
	}

	public Component add(Component c, int paramInt) {
		c.addKeyListener(this);
		return super.add(c, paramInt);
	}

	public YKDialog(Dialog paramDialog, boolean paramBoolean) {
		super(paramDialog, paramBoolean);
		init();
	}

	public YKDialog(Dialog paramDialog, String paramString, boolean paramBoolean) {
		super(paramDialog, paramString, paramBoolean);
		init();
	}

	public YKDialog(Dialog paramDialog, String paramString) {
		super(paramDialog, paramString);
		init();
	}

	public YKDialog(Dialog paramDialog) {
		super(paramDialog);
		init();
	}

	public YKDialog(Frame paramFrame, boolean paramBoolean) {
		super(paramFrame, paramBoolean);
		init();
	}

	public YKDialog(Frame paramFrame, String paramString, boolean paramBoolean) {
		super(paramFrame, paramString, paramBoolean);
		init();
	}

	public YKDialog(Frame paramFrame, String paramString) {
		super(paramFrame, paramString);
		init();
	}

	public YKDialog(Frame paramFrame) {
		super(paramFrame);
		init();
	}

	public YKDialog(Window paramWindow, String paramString) {
		super(paramWindow, paramString);
		init();
	}

	public YKDialog(Window paramWindow) {
		super(paramWindow);
		init();
	}

	public void keyTyped(KeyEvent e) {

	}

	public void keyPressed(KeyEvent e) {
		if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
			this.setVisible(false);
		}
	}

	public void keyReleased(KeyEvent e) {

	}

}
